﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GSync
{
    public partial class ConflictResolveForm : Form, IConflictResolver
    {
        public ConflictResolveForm()
        {
            InitializeComponent();
        }

        private void menuItemOk_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            if (rbnLocalVersion.Checked)
                result = UpdatePolicy.UseLocalData;
            else if (rbnRemoteVersion.Checked)
                result = UpdatePolicy.UseServerData;
            else
                result = UpdatePolicy.Cancel;
            this.Close();
        }

        private void menuItemCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.result = UpdatePolicy.Cancel;
            this.Close();
        }

        #region IConflictResolver Members

      

        UpdatePolicy result = UpdatePolicy.Cancel;

        public UpdatePolicy ResolveConflict()
        {
            this.lblLocalEntry.Text = LocalEntry.ToString();
            this.lblServerEntry.Text = RemoteEntry.ToString();
            this.ShowDialog();
            return result;
            
        }

        #endregion

        #region IConflictResolver Members

        public InternalEntry LocalEntry
        {
            get;
            set;
        }

        public InternalEntry RemoteEntry
        {
            get;
            set;
        }

        #endregion
    }
}